var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  options: {
    styleIsolation: 'shared' 
  },
  properties: {

  },
  lifetimes: {
    ready() {
        this.init();
        this._getData();
    }
  },


  /**
   * 组件的初始数据
   */
  data: {
    customer_open:true,
    show1:false,
    dataget: [],
    title: [],
    msgarr: [],
    msg: '',
    showbox: false,
    service_QRcode:'',
    service_mobile:'',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    init(){
      this.setData({
        customer_open: true,
        show1: false,
        service_QRcode: '',
        service_mobile: '',
      });
    },
    callPhone(){
      wx.makePhoneCall({
        phoneNumber: this.data.service_mobile,
  
      });
    },
    showPop(){
      if (this.data.customer_open){
        this.setData({
          show1: true
        });
      }
    },
    closePop(){
      this.setData({
        show1: false
      });
    },
    _getData() {
      var that = this;
      let urlStr = app.getNetAddresss("plugin.help-center.api.content.info");
      app._getNetWork({
        url: urlStr,
        success: function(resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            console.log(res.data.customer_service.customer_open);
            that.setData({
              dataget: res.data.set_data,
              customer_open: res.data.customer_service.customer_open=='1'?true:false,
              service_QRcode: res.data.customer_service.service_QRcode,
              service_mobile: res.data.customer_service.service_mobile,
            });
            let msgarr = that.data.msgarr;
            let title = that.data.title;
            that.data.dataget.map(response => {
              title.push(response.title);
              msgarr.push(response.content);
            });
            that.setData({
              title: title,
              msgarr: msgarr,
              msg: msgarr[0]
            });
          } else {
            wx.showToast({
              icon: 'none',
              title: res.msg,
              duration: 1500
            });
          }
        }
      });
    },
    show(e) {
      let index = e.target.dataset.index;
      this.setData({
        msg: this.data.msgarr[index],
        showbox: true
      });
      // let article = this.data.msg;
      /**
       * WxParse.wxParse(bindName , type, data, target,imagePadding)
       * 1.bindName绑定的数据名(必填)
       * 2.type可以为html或者md(必填)
       * 3.data为传入的具体数据(必填)
       * 4.target为Page对象,一般为this(必填)
       * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
       */
      // WxParse.wxParse('article', 'html', article, this);
    },
    msgboxclose() {
      this.setData({
        showbox: false,
        msg: ''
      });
    }
  }
})
